Skip to content

Flatten plot API: replace Plotter classes with module-level functions#1174

Merged
Jammy2211 merged 2 commits intomain_buildfrom
feature/plot_refactor
Apr 3, 2026
Merged

Flatten plot API: replace Plotter classes with module-level functions#1174
Jammy2211 merged 2 commits intomain_buildfrom
feature/plot_refactor

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Replace the class-based plotting API (NestPlotter, MCMCPlotter, MLEPlotter, SamplesPlotter) with simple module-level functions. Users now call aplt.corner_anesthetic(samples=samples) instead of instantiating a plotter object. All cross-cutting concerns (test-mode skipping, convergence error handling) are preserved as decorators in a new plot_util.py.

API Changes

The autofit.plot module no longer exports Plotter classes. All plotting is now done via flat functions that take samples as the first argument, with optional path, filename, and format kwargs for output control.

  • Removed: NestPlotter, MCMCPlotter, MLEPlotter, SamplesPlotter, Output
  • Added: corner_cornerpy(), corner_anesthetic(), subplot_parameters(), log_likelihood_vs_iteration(), output_figure()

See full details below.

Test Plan

  • pytest test_autofit/ -x — 390 passed (1 pre-existing failure in test_covariance.py also fails on main_build)
  • All modified files pass py_compile syntax check
  • grep confirms no stale references to old Plotter classes in source
📋 Full API Changes (for automation & release notes)

Removed

  • aplt.NestPlotter class — use aplt.corner_anesthetic() function instead
  • aplt.MCMCPlotter class — use aplt.corner_cornerpy() function instead
  • aplt.MLEPlotter class — use aplt.subplot_parameters() / aplt.log_likelihood_vs_iteration() instead
  • aplt.SamplesPlotter class — base class, no longer needed
  • aplt.Output class — output now handled via path, filename, format kwargs on each function
  • autofit.non_linear.plot.output module — deleted
  • autofit.non_linear.plot.mcmc_plotters module — deleted

Added

  • aplt.corner_cornerpy(samples, path=None, filename="corner", format="show", **kwargs) — corner plot via corner.py
  • aplt.corner_anesthetic(samples, path=None, filename="corner_anesthetic", format="show", **kwargs) — corner plot via anesthetic
  • aplt.subplot_parameters(samples, use_log_y=False, use_last_50_percent=False, path=None, filename="subplot_parameters", format="show") — parameter vs iteration subplots
  • aplt.log_likelihood_vs_iteration(samples, use_log_y=False, use_last_50_percent=False, path=None, filename="log_likelihood_vs_iteration", format="show") — log likelihood vs iteration
  • aplt.output_figure(path=None, filename="figure", format="show") — utility for saving/showing figures
  • autofit.non_linear.plot.plot_util module — shared decorators (skip_in_test_mode, log_plot_exception) and output_figure

Migration

  • Before: plotter = aplt.NestPlotter(samples=s); plotter.corner_anesthetic()
  • After: aplt.corner_anesthetic(samples=s)
  • Before: plotter = aplt.MCMCPlotter(samples=s); plotter.corner_cornerpy(**kw)
  • After: aplt.corner_cornerpy(samples=s, **kw)
  • Before: plotter = aplt.MLEPlotter(samples=s); plotter.subplot_parameters(use_log_y=True)
  • After: aplt.subplot_parameters(samples=s, use_log_y=True)
  • For file output, replace Output(path=p, format="png") with kwargs: path=p, format="png" on each function call

🤖 Generated with Claude Code

Jammy2211 and others added 2 commits April 2, 2026 20:38
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit 95223b4 into main_build Apr 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant